package bpm.dao.impl.deptagenda;

import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.List;

import org.springframework.jdbc.core.BatchPreparedStatementSetter;

import bpm.domain.deptagenda.AgendaDept;
import bpm.domain.deptagenda.AgendaUser;
import bpm.domain.deptagenda.AgendaUserRelaiton;
/**
 * RelationBatchSetter
 * @author wanglong635@126.com
 *
 */
public class AgendaUserRelationBatchSetter implements
		BatchPreparedStatementSetter {
	private List<AgendaUserRelaiton> relations;
	
	public AgendaUserRelationBatchSetter(List<AgendaUserRelaiton> relations){
		this.relations = relations;
	}
	
	public int getBatchSize() {
		return relations.size();
	}

	public void setValues(PreparedStatement ps, int i) throws SQLException {
		AgendaUserRelaiton relation = relations.get(i);
		ps.setString(1, relation.id);
		ps.setString(2, relation.agendaId);
		
		AgendaUser user = relation.leader;
		ps.setString(3, user==null?null:user.getUserId());
		ps.setString(4, user==null?null:user.getUserName());
		ps.setString(5, user==null?null:user.getUserMain());
		
		AgendaDept dept = user==null?null:user.getAgendaDept();
		ps.setString(6, dept==null?null:dept.getDeptCode());
		ps.setString(7, dept==null?null:dept.getDeptName());
		ps.setString(8, relation.index);
		ps.setString(9, user==null?null:user.getDeptPcode());
		ps.setString(10, user==null?null:user.getDeptPName());
	}

}
